var t = getApp();

Page({
  data: {
    keshi1: [],
    idIndex: 0
  },
  Click: function (e) {
    let that = this;
    console.log(e)
    var nksinfo = e.currentTarget.dataset.text
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    prevPage.setData({
      nksinfo: nksinfo
    })
    wx.navigateBack({
      delta: 1
    });
  },
  changeMenu: function (e) {
    var that = this
    var index = e.currentTarget.dataset.index
    var id = e.currentTarget.dataset.id
    var ctname = e.currentTarget.dataset.ctname
    t.util.request({
      'url': 'entry/wxapp/index.parentclass',
      data: {
        id: id,
        op: 'parent'
      },
      success: function (res) {
        console.log(res)
        that.setData({
          parks: res.data,
          ctname: ctname,
          z_room: id
        })
      }
    })
    this.setData({
      idIndex: index
    })
  },
  scroll: function (e) {
    console.log(e)
    this.setData({
      idIndex: e.detail.current
    })
  },
  onLoad: function (options) {
    var that = this
    var id = options.hosid
    //查询所有科室
    t.util.request({
      'url': 'entry/wxapp/index.address',
      data: {
        op: 'keshi',
        id: id
      },
      success: function (res) {
        console.log(res)
        var id = res.data[0].id
        //查询科室下的二级科室
        t.util.request({
          'url': 'entry/wxapp/index.parentclass',
          data: {
            id: id,
            op: 'parent'
          },
          success: function (res) {
            console.log(res)
            that.setData({
              parks: res.data
            })
          }
        })
        that.setData({
          keshi: res.data,
          ctname: res.data[0].ctname,
          z_room: id
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
    that.setData({
      id: id
    })
  },
  enterbt(e) {
    var that = this
    var z_room = that.data.z_room
    var parentid = e.currentTarget.dataset.id
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    var name = e.currentTarget.dataset.name
    console.log(z_room,parentid,name)
    prevPage.setData({
      parentid2: parentid,
      z_room: z_room,
      name:name
    })
    wx.navigateBack({
      detail: 1
    })
  }
});